home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2637 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: crc-news.doc.ca!usenet
  2. From: Slobodan Celenkovic <slobodan@cs.unh.edu>
  3. Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
  4. Subject: Re: C++ with Zapp vs. Delphi
  5. Date: 18 Jan 1996 21:06:57 GMT
  6. Organization: The Communications Research Centre
  7. Message-ID: <4dmcph$6sv@crc-news.doc.ca>
  8. References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <WaE/w0JfFiKC089yn@oslonett.no> <4dkp2c$3d7m@tigger.cc.uic.edu>
  9. NNTP-Posting-Host: celenkovic.bob.fob003.ic.gc.ca
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  14.  
  15. olczyk@sunphy1 (Jung Oh) wrote:
  16. >Rune Moberg (mobergru@oslonett.no) wrote:
  17. >: void (ah, a function returning nothing - aka procedure in Pascal)
  18. >: sort (the function name)
  19. >: void* base (uhm... An undefined pointer?)
  20. >pointer to undefined type -- like Pascal POINTER
  21.  
  22. yes, C/C++ "void*" is the same as Pascal "pointer" => a generic pointer
  23.  
  24. >: unsigned int sz (definatively an unsigned integer)
  25. >: CFT cmp (right, a variable of type CFT declared above)
  26. >
  27. >: typedef int (*CFT) (void*,void*);
  28. >: is what got me. What is this? Could it be a typedeclaring a function
  29. >: returning an int, with two undefined arguments (pointers)? It would
  30. >: probably deserve a comment (or three), or one could write it in 
  31. Pascal.
  32.  
  33. Pascal version:
  34.  
  35. type CFT = function(p1 : pointer; p2 : pointer) : integer ;
  36.  
  37. C/C++ allows you to skip the param names (p1 & p2) in the prototype.
  38.  
  39. So both declare the function TYPE called CFT with the defined prototype 
  40. (2 generic pointers and returns an integer). Idea is that the function 
  41. gets pointers to 2 objects/variables which are supposed to be compared. 
  42. Then it is supposed to returns a comparison code (smaller, larger, 
  43. equal).
  44.  
  45. >However the whole arguement  begs the question. When a method accepts a TObject
  46. >and typecasts it to other types so that it can send a method to it, the 
  47. >method's class can never be closed to change since there may be other 
  48. >classes generated later which must be typecast also.
  49. >---------------------------
  50. >Thaddeus L. Olczyk
  51.  
  52. Absolutely correct. That is exactly why use polymorphism instead of 
  53. typecasting. Typecasting hard-codes types, hence hindering future 
  54. additions of new types. Polymorhism doesn't.
  55.  
  56.